/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * InterCandado.java
 *
 * Created on 28/10/2011, 04:26:30 PM
 */
package proyecto2;

import java.awt.Cursor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

public class InterCandado extends javax.swing.JFrame {

    static ArrayList<Candado> nInformatica = new ArrayList();
    Candado cuentaTemporal;

 
    //CLASE MiModelo: se utiliza para crear una DefaulTableModel, la cual contiene todos los 
    //datos almacenados 
    public class MiModelo extends DefaultTableModel
    {
        @Override
         public boolean isCellEditable (int row, int column)
          {
            if ((column==0)&&((row==0)||(row==1)||(row==2)))
              return false;
            return true;
          }
    }
    
    MiModelo modelo;    
    
    
    /** Creates new form InterCandado */
    public InterCandado() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        save = new javax.swing.JLabel();
        registro = new javax.swing.JLabel();
        regreso = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        botonAgregar = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jScrollPane1.setViewportView(jTable1);

        save.setIcon(new javax.swing.ImageIcon(getClass().getResource("/proyecto2/save.png"))); // NOI18N
        save.setToolTipText("Guardar cambios");
        save.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                saveMouseClicked(evt);
            }
        });
        save.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                saveMouseMoved(evt);
            }
        });

        registro.setIcon(new javax.swing.ImageIcon(getClass().getResource("/proyecto2/nuevoReg.png"))); // NOI18N
        registro.setToolTipText("Nueva cuenta informática");
        registro.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                registroMouseClicked(evt);
            }
        });
        registro.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                registroMouseMoved(evt);
            }
        });

        regreso.setIcon(new javax.swing.ImageIcon(getClass().getResource("/proyecto2/regresar.png"))); // NOI18N
        regreso.setToolTipText("Regresar al inicio");
        regreso.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                regresoMouseClicked(evt);
            }
        });
        regreso.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                regresoMouseMoved(evt);
            }
        });

        jLabel4.setFont(new java.awt.Font("Euphemia", 1, 14));
        jLabel4.setText("CANDADOS");

        jLabel1.setFont(new java.awt.Font("Euphemia", 0, 12));
        jLabel1.setText("Candados con combinación:");

        botonAgregar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/proyecto2/nuevo.png"))); // NOI18N
        botonAgregar.setToolTipText("Agregar campo");
        botonAgregar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                botonAgregarMouseClicked(evt);
            }
        });
        botonAgregar.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                botonAgregarMouseMoved(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(137, 137, 137)
                        .addComponent(registro)
                        .addGap(18, 18, 18)
                        .addComponent(botonAgregar)
                        .addGap(18, 18, 18)
                        .addComponent(save, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(regreso))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(108, 108, 108)
                        .addComponent(jLabel1)
                        .addGap(18, 18, 18)
                        .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(66, 66, 66)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 397, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(59, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(220, Short.MAX_VALUE)
                .addComponent(jLabel4)
                .addGap(219, 219, 219))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(37, Short.MAX_VALUE)
                .addComponent(jLabel4)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(27, 27, 27)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(20, 20, 20)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(registro)
                        .addComponent(botonAgregar)
                        .addComponent(save))
                    .addComponent(regreso, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(23, 23, 23))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void saveMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_saveMouseClicked
        // TODO add your handling code here:
        cuentaTemporal = new Candado();
    }//GEN-LAST:event_saveMouseClicked

    private void saveMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_saveMouseMoved
        // TODO add your handling code here:
        save.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}//GEN-LAST:event_saveMouseMoved

    private void registroMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_registroMouseClicked
        // TODO add your handling code here:
        modelo = new MiModelo();
        jTable1.setModel(modelo);
        modelo.addColumn("CUENTA INFORMATICA",new String[]{"Titulo","Usuario","Contraseña"});
        modelo.addColumn("VALORES",new String[]{});
}//GEN-LAST:event_registroMouseClicked

    private void registroMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_registroMouseMoved
        // TODO add your handling code here:
        registro.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}//GEN-LAST:event_registroMouseMoved

    private void regresoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_regresoMouseClicked
        // TODO add your handling code here:
        this.setVisible(false);
}//GEN-LAST:event_regresoMouseClicked

    private void regresoMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_regresoMouseMoved
        // TODO add your handling code here:
        regreso.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}//GEN-LAST:event_regresoMouseMoved

    private void botonAgregarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_botonAgregarMouseClicked
        // TODO add your handling code here:
        String nombre = JOptionPane.showInputDialog(null,"Ingrese nombre del nuevo campo","NUEVO CAMPO",JOptionPane.QUESTION_MESSAGE);
        if(nombre!=null) {
            modelo.insertRow(modelo.getRowCount(),new Object[]{"",""});
            modelo.setValueAt(nombre, modelo.getRowCount()-1, 0);
        }
}//GEN-LAST:event_botonAgregarMouseClicked

    private void botonAgregarMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_botonAgregarMouseMoved
        // TODO add your handling code here:
        botonAgregar.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}//GEN-LAST:event_botonAgregarMouseMoved

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new InterCandado().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel botonAgregar;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JLabel registro;
    private javax.swing.JLabel regreso;
    private javax.swing.JLabel save;
    // End of variables declaration//GEN-END:variables
}
